<template>
  <div class="date-system">
    <eltable
      :table-label="tableLabel"
      :table-data="tableData.slice((currentpage-1)*pagesize,currentpage*pagesize)"
    >
      <el-table-column slot="first" label="课程名称" align="center" min-width="20">
        <template slot-scope="scope">
          <el-button type="text">{{ scope.row.title }}</el-button>
        </template>
      </el-table-column>
      <el-table-column slot="isEnd" label="授课教师" align="center" min-width="10">
        <template slot-scope="scope">
          <el-button type="text">{{ scope.row.userName }}</el-button>
        </template>
      </el-table-column>
    </eltable>
    <pagination
      :total="total"
      :current-page="currentpage"
      :page-size="pagesize"
      @handleSizeChange="handleSizeChange"
      @handleCurrentChange="handleCurrentChange"
    />
  </div>
</template>

<script>
import Eltable from '@/components/Eltable'
import Pagination from '@/components/Pagination'
import { getArrangeList } from '@/api/subject/course' // 数据接口
import { getTenantId } from '@/utils/auth'
export default {
  components: {
    Eltable,
    Pagination
  },
  data() {
    return {
      total: 0,
      currentpage: 1,
      pagesize: 10,
      value: '',
      tableLabel: [
        {
          label: '可预约课次', width: '10', prop: 'reserveNum'
        },
        {
          label: '已预约课次', width: '10', prop: 'bespeakNum'
        },
        {
          label: '已完成课次', width: '10', prop: 'finishNum'
        }
      ],
      tableData: [],
      listFilter: []
    }
  },
  mounted() {
    this.getData()
  },
  methods: {
    handleSizeChange(val) {
      console.log(val)
      this.currentpage = 1
      this.pagesize = val.value
      if (this.pagesize >= 20) {
        scrollTo(50, 800)
      }
    },
    handleCurrentChange(val) {
      console.log(val)
      this.currentpage = val.value
      if (this.pagesize >= 20) {
        scrollTo(50, 800)
      }
    },
    getData() {
      getArrangeList(getTenantId()).then(res => {
        this.tableData = res.data.items
        this.listFilter = res.data.items
        this.total = res.data.items.length
      })
    }
  }
}
</script>

<style lang="scss" scoped>
.date-system {
  margin-top: 0px;
  width: 100%;
  // padding: 14px 20px 21px 20px;
  .list {
    height: 110px;
    text-align: center;
  }
  .search {
    margin-top: 5px;
    padding: 15px 20px;
    background-color: #e5e7ea;
    border-radius: 5px;
  }
}
</style>
